<template>
  <div class="app-container">
    <el-tabs v-model="type" @tab-click="changeType">
      <el-tab-pane label="维修单" name="first"></el-tab-pane>
      <el-tab-pane label="报废单" name="second"></el-tab-pane>
    </el-tabs>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" @click="save" size="mini">保存</el-button>
        <el-button @click="$emit('change','List')" size="mini">返回</el-button>
      </el-col>
    </el-row>
    <template v-if="type==='first'">
      <el-form ref="form" :rules="rules" :model="form" label-width="110px">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="单据号" prop="q">
              <el-input v-model="form.q" :readonly="isReadOnly" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="设备编号" prop="q">
              <el-input v-model="form.q" :readonly="isReadOnly" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="设备名称" prop="q">
              <el-input v-model="form.q" :readonly="isReadOnly" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="日期" prop="q">
              <el-date-picker
                :readonly="isReadOnly"
                style="width: 100%;"
                v-model="form.q"
                type="date"
                placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="维修班组" prop="q">
              <el-select style="width: 100%;" v-model="form.w" :readonly="isReadOnly" placeholder="请选择">
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="使用类型" prop="q">
              <el-select style="width: 100%;" v-model="form.w" :readonly="isReadOnly" placeholder="请选择">
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="使用单位" prop="q">
              <el-select style="width: 100%;" v-model="form.w" :readonly="isReadOnly" placeholder="请选择">
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="故障地点" prop="q">
              <el-input v-model="form.q" :readonly="isReadOnly" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="检查开始时间" prop="q">
              <el-date-picker
                :readonly="isReadOnly"
                style="width: 100%;"
                v-model="form.q"
                type="date"
                placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="检查结束时间" prop="q">
              <el-date-picker
                :readonly="isReadOnly"
                style="width: 100%;"
                v-model="form.q"
                type="date"
                placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="制单人" prop="q">
              <el-select style="width: 100%;" v-model="form.w" :readonly="isReadOnly" placeholder="请选择">
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="完成时间" prop="q">
              <el-date-picker
                :readonly="isReadOnly"
                style="width: 100%;"
                v-model="form.q"
                type="date"
                placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="备注" prop="q">
              <el-input v-model="form.q" :readonly="isReadOnly" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="故障描述" prop="q">
              <el-input v-model="form.q" :readonly="isReadOnly" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="明细" name="first"></el-tab-pane>
        <el-tab-pane label="配件" name="second"></el-tab-pane>
      </el-tabs>
      <template v-if="activeName==='first'">
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button @click="handleAdd1" size="mini">新增</el-button>
            <el-button @click="handleDelete1" size="mini">删除</el-button>
          </el-col>
        </el-row>
        <el-table :data="listDetail1" @selection-change="handleSelectionChange1">
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column label="维修项目" prop="q">
            <template slot-scope="scope">
              <el-input v-model="scope.row.q" placeholder="请输入"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="维修内容" prop="w">
            <template slot-scope="scope">
              <el-input v-model="scope.row.w" placeholder="请输入"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="维修结果" prop="e">
            <template slot-scope="scope">
              <el-input v-model="scope.row.e" placeholder="请输入"></el-input>
            </template>
          </el-table-column>
        </el-table>
      </template>
      <template v-if="activeName==='second'">
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button @click="handleAdd2" size="mini">新增</el-button>        
            <el-button @click="handleDelete2" size="mini">删除</el-button>
          </el-col>
        </el-row>
        <el-table :data="listDetail2" @selection-change="handleSelectionChange2">
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column label="行号" prop="q">
            <template slot-scope="scope">
              <el-input v-model="scope.row.q" placeholder="请输入"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="是否收费" prop="q">
            <template slot-scope="scope">
              <el-input v-model="scope.row.q" placeholder="请输入"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="材料名称" prop="q">
            <template slot-scope="scope">
              <el-input v-model="scope.row.q" placeholder="请输入"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="材料类别" prop="q">
            <template slot-scope="scope">
              <el-input v-model="scope.row.q" placeholder="请输入"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="材料规格" prop="q">
            <template slot-scope="scope">
              <el-input v-model="scope.row.q" placeholder="请输入"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="单位" prop="q">
            <template slot-scope="scope">
              <el-input v-model="scope.row.q" placeholder="请输入"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="数量" prop="q">
            <template slot-scope="scope">
              <el-input v-model="scope.row.q" placeholder="请输入"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="备注" prop="q">
            <template slot-scope="scope">
              <el-input v-model="scope.row.q" placeholder="请输入"></el-input>
            </template>
          </el-table-column>
        </el-table>
      </template>
    </template>
    <template v-if="type==='second'">
      <el-form ref="scrapForm" :rules="scrapRules" :model="scrapForm" label-width="110px">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="单据号" prop="q">
              <el-input v-model="scrapForm.q" :readonly="isReadOnly" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="设备编号" prop="q">
              <el-input v-model="scrapForm.q" :readonly="isReadOnly" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="设备名称" prop="q">
              <el-input v-model="scrapForm.q" :readonly="isReadOnly" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="登记日期" prop="q">
              <el-date-picker
                style="width: 100%;"
                :readonly="isReadOnly"
                v-model="scrapForm.q"
                type="date"
                placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="所属资源" prop="q">
              <el-input v-model="scrapForm.q" :readonly="isReadOnly" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="生产编号" prop="q">
              <el-input v-model="scrapForm.q" :readonly="isReadOnly" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="申请日期" prop="q">
              <el-date-picker
                style="width: 100%;"
                :readonly="isReadOnly"
                v-model="scrapForm.q"
                type="date"
                placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="使用登记时间" prop="q">
              <el-date-picker
                style="width: 100%;"
                :readonly="isReadOnly"
                v-model="scrapForm.q"
                type="date"
                placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="责任部门" prop="q">
              <el-select style="width: 100%;" v-model="scrapForm.w" :readonly="isReadOnly" placeholder="请选择">
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="使用单位" prop="q">
              <el-select style="width: 100%;" v-model="scrapForm.w" :readonly="isReadOnly" placeholder="请选择">
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="报废种类" prop="q">
              <el-select style="width: 100%;" v-model="scrapForm.w" :readonly="isReadOnly" placeholder="请选择">
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="所有权单位" prop="q">
              <el-select style="width: 100%;" v-model="scrapForm.w" :readonly="isReadOnly" placeholder="请选择">
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="经办人" prop="q">
              <el-select style="width: 100%;" v-model="scrapForm.w" :readonly="isReadOnly" placeholder="请选择">
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="制单人" prop="q">
              <el-select style="width: 100%;" v-model="scrapForm.w" :readonly="isReadOnly" placeholder="请选择">
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="报废理由" prop="q">
              <el-input v-model="scrapForm.q" :readonly="isReadOnly" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="备注" prop="q">
              <el-input v-model="scrapForm.q" :readonly="isReadOnly" type="textarea" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </template>
  </div>
</template>

<script>

export default {
  data() {
    return {
      // 下拉数据
      options: [],
      // 选择列表
      ids1: [],
      ids2: [],
      ids3: [],
      // tab
      type: 'first',
      // 是否只读
      isReadOnly: false,
      // 维修单表单
      activeName: 'first',
      rules: {},
      form: {},
      // 明细配件字段
      listDetail1: [],
      listDetail2: [],
      // 报废单
      scrapRules: {},
      scrapForm: {}
    };
  },
  created() {
    
  },
  methods: {
    // 改变大类维修单报废单
    changeType() {

    },
    // 保存
    save() {
      if (this.type==='first') {

      } else {

      }
    },
    // 选择
    handleSelectionChange1() {

    },
    handleSelectionChange2() {

    },
    handleSelectionChange3() {

    },
    // 明细配件改变
    handleClick() {
      this.queryDetail.pageNum = 1
    },
    // 明细配件新增
    handleAdd1() {
      this.listDetail1.push({ q: '',w: '',e:''})
    },
    handleAdd2() {
      this.listDetail2.push({ q: ''})
    }
  }
};
</script>
